<template>
    <view class="g_content p_t_10">
        <!--        <uni-card :is-shadow="false">-->
        <!--           <view class="c_16"> 团队业绩：<text style="color: #fa3534"> {{ teamAmount }}元</text></view>-->
        <!--        </uni-card>-->
        <!--        <uni-card :is-shadow="false">-->
        <view class="bg_f p_20" style="border-radius: 20rpx">
            <view class="dis_f_sb_c">
                <view>成员信息</view>
            </view>
            <u-divider></u-divider>
            <scroll-view style="min-height: 80vh"  scroll-y="true" refresher-enabled="true" :refresher-triggered="triggered" refresher-background="#f8f4f3" @refresherrefresh="onRefresh" @scrolltolower='lower'>
                <view v-for="(item,index) in list" :key="index">
                    <view class="dis_f_sb_c">
                        <view class="dis_f_l_c">
                            <u-avatar :src="item.wxAvatar" shape="square" size="60"></u-avatar>
                            <view class="m_l_10">
                                <view class="f_s_14">{{item.nickName}}</view>
                            </view>
                        </view>
                        <view> <u-button type="primary" size="mini" @click="handleToSecondLevel(item.userId)">查看下级成员</u-button> </view>
                    </view>
                    <u-divider></u-divider>
                </view>
                <uni-load-more :status="loadStatus" :contentText="contentText" />
            </scroll-view>
        </view>
        <!--        </uni-card>-->
    </view>
</template>
<script>
import {getMyTeamApi} from "@/sheep/api/index";
export default {
    name: "myTeam",
    data() {
        return {
            teamAmount:'',
            triggered: false,
            loadStatus: "noMore",
            contentText: {
                contentdown: "查看更多",
                contentrefresh: "加载中",
                contentnomore: "没有更多了",
            },
            paramsPage: {
                pageNum: 1,
                pageSize: 10,
                status:"1"
            },
            list:[]
        }
    },
    onShow() {
        this.list = [];
        this.paramsPage.pageNum = 1;
        this.getList();
    },
    methods: {
        getList(){
            getMyTeamApi(this.paramsPage).then(res=>{
                this.list = this.list.concat(res.data.team.records);
                this.teamAmount = res.data.teamAmount;
                this.triggered = false;
                if (res.data.team.records?.length < this.paramsPage.pageSize) {
                    this.loadStatus = "noMore";
                } else {
                    this.loadStatus = "more";
                }
            })
        },
        // 下拉刷新
        onRefresh() {
            this.triggered = true;
            this.list = [];
            this.paramsPage.pageNum = 1;
            this.getList();
        },
        // 触底了
        lower() {
            if (this.loadStatus !== "noMore") {
                this.paramsPage.pageNum++;
                this.getList();
            }
        },
        handleToSecondLevel(userId){
            uni.navigateTo({
                url: '/pages/mine/secondLevel?userId='+userId
            })
        }
    }
}
</script>

<style scoped lang="scss">

</style>
